package de.ars.client.items.animators;

import de.ars.client.animator.AbstractSlideItemAnimator;
import de.ars.client.animator.IAnimationEventListener;
import de.ars.client.animator.Point;
import de.ars.client.paintSystems.ClassicLayout;

public class AddAttributeItemAnimator extends AbstractSlideItemAnimator
{
	public static final float STANDARD_ANIMATION_SPEED = 5f;
    public static final float STANDARD_SCROLL_SPEED = 10.0f;
    
    public static final int POINT_ADD_POS = 0;
    public static final int POINT_ADD_SIZE = 1;
    public static final int POINT_ADD_TEXT_POS = 2;
    
	private ClassicLayout layout;
	
	public AddAttributeItemAnimator(IAnimationEventListener listener) 
	{
		super(listener);
	}
	
	public void setLayout(ClassicLayout layout)
    {
        this.layout = layout;
    }
	
	public void openItem()
	{
		this.startAnimationTo(POINT_ADD_POS, this.layout.getAddPersonOptionPos(), STANDARD_ANIMATION_SPEED);
		this.startAnimationTo(POINT_ADD_TEXT_POS, this.layout.getAddPersonOptionTextPos(), STANDARD_ANIMATION_SPEED);
		
		listener.animationEvent(IAnimationEventListener.ANIMATION_STARTED);
	}
	
	public void closeItem()
	{
		this.startAnimationTo(POINT_ADD_POS, this.layout.getAddPersonOptionClosePos(), STANDARD_ANIMATION_SPEED);
		this.startAnimationTo(POINT_ADD_TEXT_POS, this.layout.getAddPersonOptionCloseTextPos(), STANDARD_ANIMATION_SPEED);
		
		listener.animationEvent(IAnimationEventListener.ANIMATION_STARTED);
	}
	
	public void animateScrollUp(int alpha)
    {
        Point tempPoint = this.getPoint( POINT_ADD_TEXT_POS );
        tempPoint.setY( tempPoint.getY() +alpha );
        startAnimationTo( POINT_ADD_TEXT_POS, tempPoint,STANDARD_SCROLL_SPEED );
        
        listener.animationEvent(IAnimationEventListener.ANIMATION_STARTED);
    }
    
    public void animateScrollDown(int alpha)
    {
        Point tempPoint = this.getPoint( POINT_ADD_TEXT_POS );
        tempPoint.setY( tempPoint.getY() -alpha );
        startAnimationTo( POINT_ADD_TEXT_POS, tempPoint,STANDARD_SCROLL_SPEED );
        
        listener.animationEvent(IAnimationEventListener.ANIMATION_STARTED);
    }
}